Skip to content

feat: 통계 API 연동#198

Merged
jihun32 merged 4 commits intodevelopfrom
feat/#197
Feb 25, 2026
Merged

feat: 통계 API 연동#198
jihun32 merged 4 commits intodevelopfrom
feat/#197

Conversation

@jihun32
Copy link
Contributor

@jihun32 jihun32 commented Feb 25, 2026

🔗 관련 이슈

📙 작업 내역

  • StatsView/Reducer fetchStats liveValue구현

🎨 스크린샷 또는 시연 영상 (선택)

기능 미리보기 기능 미리보기
진행 종료

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ace6462 and cbe163f.

📒 Files selected for processing (13)
  • Projects/Core/Network/Interface/Sources/Endpoint.swift
  • Projects/Domain/Stats/Interface/Sources/DTO/StatsResponseDTO.swift
  • Projects/Domain/Stats/Interface/Sources/Endpoint/StatsEndpoint.swift
  • Projects/Domain/Stats/Interface/Sources/Entity/Stats.swift
  • Projects/Domain/Stats/Interface/Sources/StatsClient.swift
  • Projects/Domain/Stats/Sources/StatsClient+Live.swift
  • Projects/Feature/Stats/Example/Sources/StatsApp.swift
  • Projects/Feature/Stats/Interface/Sources/Stats/StatsReducer.swift
  • Projects/Feature/Stats/Project.swift
  • Projects/Feature/Stats/Sources/Stats/StatsReducer+Impl.swift
  • Projects/Feature/Stats/Sources/Stats/StatsView.swift
  • Projects/Shared/DesignSystem/Sources/Components/Card/Stats/Model/StatsCardItem.swift
  • Projects/Shared/DesignSystem/Sources/Components/Card/Stats/View/StatsCardView.swift

📝 Walkthrough

통계 API 연동 구현

개요

통계 화면(StatsView)에 API 연동을 구현한 PR입니다. 기존 이진 상태(진행중/종료) 기반 API 호출을 단일 통합 메서드로 리팩토링하고, 사용자별 완료 횟수 및 스탬프 색상을 표시하는 새로운 데이터 구조를 도입했습니다. (관련 issue: #197)

아키텍처 변경사항

Dependency/Client 간소화

  • StatsClient의 API 메서드를 fetchOngoingStats(String), fetchCompletedStats(String) 두 개에서 단일 메서드 fetchStats(String, Bool)로 통합
    • 두 번째 Bool 파라미터가 진행중(true)/종료(false) 상태를 제어
  • 새로운 StatsClient+Live.swift에서 실제 네트워크 구현 제공
    • networkClient를 통해 StatsEndpoint.fetchStats 호출
    • response를 StatsResponseDTO로 디코딩 후 toEntity(isInProgress:) 메서드로 도메인 entity로 변환

State & Action Flow 업데이트

  • StatsReducer.State에서 hasItems computed property 제거
    • StatsView에서 !store.items.isEmpty 직접 체크로 변경
  • StatsReducer+Impl.swift에서 단일 fetchStats 호출로 통합
    • 기존 두 개의 별도 호출 대신 isOngoing 플래그 기반 단일 호출로 간소화

Entity 구조 변경

  • Stats.StatsItem에서 완료 횟수 기반 시스템을 Stamp 기반 시스템으로 전환
    • 이전: myCompletedCount, partnerCompletedCount (Int)
    • 현재: myStamp, partnerStamp (Stamp 구조체)
      • 각 Stamp는 completedCount: IntstampColors: [StampColor] 포함
  • 새로운 Stats.StampColor enum으로 스탬프 색상 표현

UI 컴포넌트 업데이트

  • StatsCardItemstampIcon: TXVector.Icon 추가 (목표별 아이콘)
  • StatsCardItem.CompletionInfostampColors: [StampColor] 추가
  • StatsCardView에서 색상 렌더링 로직 변경
    • 무작위 색상 배열 대신 완료 정보별 stampColors 사용

네트워크 & DTO

  • 새 endpoint: StatsEndpoint.fetchStats(selectedDate: String, status: String)
  • 새 DTO: StatsResponseDTO (response decoding용)
    • 변환 메서드 toEntity(isInProgress:) 구현으로 도메인 entity 생성
  • Endpoint.FeatureTagstats case 추가

사용자 영향

  • UI: "스탐프 통계" 화면에서 진행중/종료 탭별로 습관 카드 표시 (각 카드는 사용자별 완료 횟수 + 스탬프 색상 표시)
  • Empty state 처리 개선으로 깜빡임 제거

테스트 커버리지

  • 기존 testValue/previewValue를 새로운 fetchStats 시그니처로 업데이트
  • StatsApp 예제에서 .previewValue 사용으로 변경

Walkthrough

통계 API 연동을 위한 네트워크 엔드포인트, 데이터 전송 객체(DTO), 클라이언트 API를 추가하고, 기존 클라이언트 인터페이스를 통합하며, 스탬프 시스템으로 엔티티 모델을 업데이트하고, UI 컴포넌트와 리듀서 로직을 연결했습니다.

Changes

Cohort / File(s) Summary
네트워크 엔드포인트 정의
Projects/Core/Network/Interface/Sources/Endpoint.swift, Projects/Domain/Stats/Interface/Sources/Endpoint/StatsEndpoint.swift
FeatureTag 열거형에 stats 케이스 추가 및 새로운 StatsEndpoint 정의로 /api/v1/stats GET 엔드포인트 구성. selectedDate와 status 쿼리 파라미터 포함.
데이터 전송 객체 및 응답 처리
Projects/Domain/Stats/Interface/Sources/DTO/StatsResponseDTO.swift, Projects/Domain/Stats/Interface/Sources/Entity/Stats.swift
StatsResponseDTO 추가로 API 응답 디코딩 지원. Stats 엔티티에 스탬프 시스템(Stamp, StampColor) 도입하여 기존 완료 카운터 대체. toEntity() 변환 메서드로 DTO에서 도메인 엔티티로 변환 로직 구현.
클라이언트 API 및 라이브 구현
Projects/Domain/Stats/Interface/Sources/StatsClient.swift, Projects/Domain/Stats/Sources/StatsClient+Live.swift
StatsClient 인터페이스를 fetchStats(String, Bool)로 통합하여 fetchOngoingStats/fetchCompletedStats 제거. 라이브 구현 추가로 networkClient를 통해 실제 API 호출 및 응답 변환 처리.
기능 통합 및 상태 관리
Projects/Feature/Stats/Interface/Sources/Stats/StatsReducer.swift, Projects/Feature/Stats/Sources/Stats/StatsReducer+Impl.swift, Projects/Feature/Stats/Sources/Stats/StatsView.swift, Projects/Feature/Stats/Project.swift
hasItems 속성 제거 및 조건부 렌더링을 !items.isEmpty로 변경. StatsReducer+Impl에서 새 fetchStats API 호출 적용 및 스탬프 기반 데이터 매핑. 도메인 의존성 추가.
UI 컴포넌트 업데이트
Projects/Shared/DesignSystem/Sources/Components/Card/Stats/Model/StatsCardItem.swift, Projects/Shared/DesignSystem/Sources/Components/Card/Stats/View/StatsCardView.swift
StatsCardItem에 stampIcon 및 StampColor 속성 추가. CompletionInfo에 stampColors 지원 추가. StatsCardView에서 항목별 스탬프 아이콘 및 색상 매핑 로직 구현.
예제 앱
Projects/Feature/Stats/Example/Sources/StatsApp.swift
DomainStats 임포트 추가 및 statsClient 의존성을 testValue에서 previewValue로 변경.

Sequence Diagram

sequenceDiagram
    actor User
    participant StatsView
    participant StatsReducer as StatsReducer<br/>(Impl)
    participant StatsClient
    participant NetworkClient
    participant API as Stats API
    participant StatsResponseDTO
    participant Stats as Stats Entity

    User->>StatsView: 월 선택 또는 뷰 진입
    StatsView->>StatsReducer: fetchStats 액션 전송
    StatsReducer->>StatsClient: fetchStats(month, isInProgress)
    StatsClient->>NetworkClient: 요청 생성<br/>(selectedDate, status)
    NetworkClient->>API: GET /api/v1/stats<br/>(쿼리 파라미터 포함)
    API-->>NetworkClient: StatsResponseDTO 응답
    NetworkClient-->>StatsClient: 디코딩된 DTO 반환
    StatsClient->>StatsResponseDTO: toEntity(isInProgress)
    StatsResponseDTO->>Stats: 도메인 엔티티 변환<br/>(스탬프 데이터 매핑)
    Stats-->>StatsResponseDTO: Stats 객체 반환
    StatsResponseDTO-->>StatsClient: Stats 반환
    StatsClient-->>StatsReducer: Stats 전달
    StatsReducer->>StatsReducer: 상태 업데이트<br/>(items, stampIcon, stampColors 매핑)
    StatsReducer-->>StatsView: 업데이트된 상태
    StatsView->>StatsView: StatsCardView 렌더링<br/>(stampIcon, stampColors 표시)
    StatsView-->>User: 통계 카드 화면 표시
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#197

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@clxxrlove
Copy link
Member

@coderabbitai summary

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

@clxxrlove, PR 요약을 생성하겠습니다.

✅ Actions performed

Summary regeneration triggered.

@jihun32 jihun32 merged commit a1fb4af into develop Feb 25, 2026
6 checks passed
@jihun32 jihun32 deleted the feat/#197 branch February 25, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants